package com.ruoyi.ichen.rabbitmq.day3;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.ruoyi.ichen.rabbitmq.common.RabbitMQUtils;

import java.io.IOException;

/**
 * @author ichen
 * @version V1.0
 * @ClassName: Provider
 * @Description: 生产者
 * @Date 2020/8/10 22:58
 */
public class Provider {

    public static void main(String[] args) throws IOException {
        //获取对象
        Connection connection = RabbitMQUtils.getConnection();
        Channel channel = connection.createChannel();
        //将通道声明交换机，
        //参数1:交换机名称,参数2:交换机类型, fanout 广播类型
        channel.exchangeDeclare("ichen","fanout");

        //发送消息
        channel.basicPublish("ichen","",null,"fanout type message".getBytes());
        //释放资源
        RabbitMQUtils.closeConnectionAndChannel(channel,connection);

    }
}
